<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<style>
    .jumpcert{color: #409EFF!important;cursor: pointer;}
</style>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
<!--                    <div class="layui-col-md3">-->
<!--                        <label class="layui-form-label">所属单位</label>-->
<!--                        <div class="layui-input-block">-->
<!--                            <div id="chanid" class="xmselect_div">-->
<!--                                <div class="xmselect_title">请选择</div>-->
<!--                            </div>-->
<!--                        </div>-->
<!--                    </div>-->
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="engin_name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
<!--                    <div class="layui-col-md3">-->
<!--                        <label class="layui-form-label">申请日期</label>-->
<!--                        <div class="layui-input-block">-->
<!--                            <input type="text" name="created_at" placeholder="请输入" class="layui-input bdate_ymd" autocomplete="off">-->
<!--                        </div>-->
<!--                    </div>-->
<!--                    <div class="layui-col-md3 search_hide none">-->
<!--                        <label class="layui-form-label">申请类型</label>-->
<!--                        <div class="layui-input-block">-->
<!--                            <select class="layui-input" id="apply_type" name="apply_type">-->
<!--                                <option value="">请选择</option>-->
<!--                            </select>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                    <div class="layui-col-md3 search_hide none">-->
<!--                        <label class="layui-form-label">用证项目</label>-->
<!--                        <div class="layui-input-block">-->
<!--                            <input type="text" name="enginid" placeholder="请输入" class="layui-input" autocomplete="off">-->
<!--                        </div>-->
<!--                    </div>-->
<!--                    <div class="layui-col-md3 search_hide none">-->
<!--                        <label class="layui-form-label">截标日期</label>-->
<!--                        <div class="layui-input-block">-->
<!--                            <input type="text" name="dt" placeholder="请输入" class="layui-input bdate_ymd" autocomplete="off">-->
<!--                        </div>-->
<!--                    </div>-->
<!--                    <div class="layui-col-md3 search_hide none">-->
<!--                        <label class="layui-form-label">审核状态</label>-->
<!--                        <div class="layui-input-block">-->
<!--                            <select id="status" name="status" lay-filter="status">-->
<!--                                <option value="">请选择</option>-->
<!--                                <option value="1">流程（审批通过）</option>-->
<!--                                <option value="0">流程（审批中）</option>-->
<!--                            </select>-->
<!--                        </div>-->
<!--                    </div>-->


                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('查看','{{d.LAY_TABLE_INDEX}}')">查看</a>
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>
    var currButAuth, currTabData, queryStatus = 0, sea_chanid = '';
    var cols = [];
    layui.use(['table','form','soulTable'], function () {
        var table = layui.table, form = layui.form, soulTable = layui.soulTable;

        $('#TableSearchReset').click(function () {
            sea_chanid='';
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        facade.ajax({type: 'get', url: ask_cert_use_bid_count, async: false}).done(function(res){
            if (res.code === 2000) {
                cols = res.data.cols;
            }
        });

        setSouTableExport('投标用证一览');
        table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_cert_use_bid_count),where: {}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response
            ,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text
            ,parseData: function (res) {
                currButAuth = res.data.butauth;
                tableButShow(currButAuth);

                if(queryStatus === 0){
                    var apply_typeArr = res.data.apply_type;
                    var apply_type_str = '<option value="">请选择</option>';
                    for(var i in apply_typeArr){
                        apply_type_str += '<option value="'+i+'">'+apply_typeArr[i]+'</option>';
                    }
                    $('#apply_type').html(apply_type_str);

                    queryStatus = 1;
                }

                xmselect_dan('chanid', res.data.chanid, sea_chanid, function (res) {
                    sea_chanid = res.arr && res.arr.length > 0 ?  res.arr[0].value : '';
                    searchTableFunc(form, table);
                });

                $('.xmselect_title').remove();
                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [cols]
            , done: function (res) {
                soulTable.render(this);

                currTabData = res.data;
                $.each(currTabData, function(index,item){
                    var chk = $('tr[data-index=' + item.LAY_TABLE_INDEX + '] .tab-list-authbut');
                    for (var key in currButAuth) {
                        if(currButAuth[key].pagetype === 0 || currButAuth[key].pagetype === 1){
                            if(currButAuth[key].butname === 'delete'){
                                if(item.isturn === 0){
                                    chk.append(' <a ' +
                                        'href="javascript:;" ' +
                                        'class="bar_opt layui-hide" ' +
                                        'lay-event="search" ' +
                                        'data-butname="'+currButAuth[key].butname+'" ' +
                                        'data-title="'+currButAuth[key].title+'" ' +
                                        'onclick="auth_but_func_'+currButAuth[key].butname+'(\''+currButAuth[key].title+'\', '+index+')"' +
                                        '>'+currButAuth[key].title+'' +
                                        '</a>');
                                }
                            }else{
                                chk.append(' <a ' +
                                    'href="javascript:;" ' +
                                    'class="bar_opt layui-hide" ' +
                                    'lay-event="search" ' +
                                    'data-butname="'+currButAuth[key].butname+'" ' +
                                    'data-title="'+currButAuth[key].title+'" ' +
                                    'onclick="auth_but_func_'+currButAuth[key].butname+'(\''+currButAuth[key].title+'\', '+index+')"' +
                                    '>'+currButAuth[key].title+'' +
                                    '</a>');
                            }
                        }
                    }
                });
                show_tab_but(currTabData);
            }
        });

        listTableSearch(form, table);

        table.on('tool(datalist)', function(obj){
            var data = obj.data;
            if(obj.event === 'name'){
                if(data.enginid != 0){
                    openPage('../bid/show.php?id='+data.id);
                }
            }
        });
    });

    // 跳转
    function jump_cert (id) {
        openPage('../cert/show.php?id='+id);
    }

    function auth_but_func_show(buttitle, index){
        var trData = currTabData[index];
        openPage('../cert_use_bid/show.php?id='+trData.id);
    }
    function auth_but_func_add_flow(){
        openPageEdit('../cert_use_bid/flow_add.php?close=1&type=1');
    }
    function auth_but_func_add(buttitle, index){
        var trData = currTabData[index];
        openPageEdit('../cert_use/add.php?close=1&type=1');
    }
    function auth_but_func_edit(buttitle, index){
        var trData = currTabData[index];
        openPageEdit('../cert_use/edit.php?close=1&id='+trData.id);
    }
    function auth_but_func_delete(buttitle, index){
        var trData = currTabData[index];
        data_delete(ask_cert_use_del, {id:trData.id});
    }
    function auth_but_func_muldel(buttitle){
        var idArr = get_table_check_idarr();
        if(idArr.length < 1){
            facade.error(buttitle + "：请选择数据");return false;
        }
        data_delete(ask_cert_use_del, {id: idArr.join(',')});
    }
</script>
</body>
</html>
